/*
 * Created on Jun 24, 2005
 */
package org.vectrics.recruiter.job.event;

import java.util.Locale;
import java.util.Set;

import org.apache.log4j.Logger;
import org.vectrics.event.Event;
import org.vectrics.event.EventEmailBuilder;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.user.PersonSearchCriteria;

/**
 * @author MMoore
 */
public class JobChangeEventHandler extends JobEventHandler {
	private transient Logger log = Logger.getLogger(this.getClass());

	/**
	 * Constructor 
	 */
	public JobChangeEventHandler() {
		super();
	}
	
	protected EventEmailBuilder getEmailBuilder(Event event, Locale locale) {
		return(new JobChangeEmailBuilder(event, this.getJob(), locale));
	}
	
	protected void doHandleEvent(Event event) {
		log.debug("doHandleEvent(Event event) called");
	}
	
	protected Set findNotifyPersons() {
		Set notifyPersons = super.findNotifyPersons();
		
		PersonSearchCriteria criteria = CoreServiceLocator.createPersonSearchCriteria();
		criteria.addDomain(this.getJob().getDomain());
		criteria.addPrivilege("job.edit.notify");
		notifyPersons.addAll(CoreServiceLocator.getPersonService().findPersons(criteria, 0, 1000));
		
		return(notifyPersons);
	}
	

}
